

function say() {
    alert("599. 两个列表的最小索引总和");
}
say();


/**
 * @param {string[]} list1
 * @param {string[]} list2
 * @return {string[]}
 */
var findRestaurant = function(list1, list2) {
    //4:20-35
    var map = new Map()
    for(var i = 0; i < list1.length; i++){
        map.set(list1[i], i)
    }

    var dic = {}
    var minFrency = 5000
    for(var i = 0; i < list2.length; i++){
        if(map.has(list2[i])){
            dic[list2[i]] = i + map.get(list2[i])
            minFrency = Math.min(minFrency, dic[list2[i]])
        }
    }

    var res = []
    for(var key in dic){
        if(dic[key] == minFrency){
            res.push(key)
        }
    }
    return res
};
